<?php

class BulletinAction extends CommonAction {
	
	public function export(){
		$filename="导出的文件名.xls";
		header ('Content-type: application/x-msexcel'); 
		header ("Content-Disposition: attachment; filename=$filename" );
		
		echo "学号\t";
		echo "姓名\t\n";
		
		for($i=0;$i<10;$i++){
		    echo $i."\t";
		    echo "姓名".$i."\t\n";
		}
	} 

	public function getModule(){
		$data1 = array();
		$names = array($data1);
		$condition['parentid'] =  $_REQUEST ['code'] ;
		$condition['status'] = 1 ;
		$model = M ( "module" );
		$list = $model->getField('id,name',$condition);
		if(count($list)==0){
			//什么也不做，code写得有点哈！！！
		}
		$this->ajaxReturn(count($list)==0?$names: $list,$_REQUEST ['code'],200,'COMBOX');
	}

	public function  popup(){
		$this->display();
	}

	public function bulletinEdit() {
		$content = $_REQUEST ['content'];
		$name = $this->getActionName ();
		$model = D ( $name );
		$data ["title"] = "测试";
		$data ["content"] = stripslashes($content);
		$data ["module"] = "关于我们";
		$data ["status"] = 1;
		$condition['id'] = $_REQUEST['id'] ;
	  
		$result = $model->where($condition)->save($data);
		$this->ajaxReturn ( "111111", "OK！", 1 );

	}



	public function bulletinInsert(){

		$mark = $_REQUEST ['mark'];
		$id = $_REQUEST ['id'];
		$title = $_REQUEST ['title'];
		$content = $_REQUEST ['editorcontent'];
		$module = $_REQUEST ['module'];
		$submodule = $_REQUEST ['submodule'];
		$author = $_REQUEST ['author'];
		$rel = $_REQUEST ['rel'];
		$summary = $_REQUEST ['summary'];
		$imageurl = $_REQUEST ['imageurl'];
		$submodule = $_REQUEST ['submodule'];
		$publishindex = $_REQUEST ['publishindex'];
		//dump($publishindex)  ;
		//echo($xFilePath) ;


		$name = $this->getActionName ();
		$model = M ( $name );
		$data ["title"] = $title;
		$data ["content"] = stripslashes($content);
		$data ["module"] = $module;
		$data ["status"] = 1;
		$data ["author"] = $author;
		$data ["rel"] = $rel;
		$data ["createdate"] = date('Y-m-d H:i:s',time());

		$data ["summary"] = $summary;
		$data ["imageurl"] = $imageurl;
		$data ["submodule"] = $submodule;
		$data["publishindex"] = $publishindex ;
		$data["submodule"] = $submodule ;
	  
	  
		//dump($data) ;
	  
		$condition['id'] = $id;
	  
		$msg = "" ;
	  
		/*
		 if ($mark=="edit"){
		 $result = $model->where($condition)->save($data);
		 if($result!=false){
		 $msg = "修改文章成功!"  ;
		 }else{
		 $msg = "修改文章失败!"  ;
		 }
	   
		 }else{
		 $result = $model->add($data);
		 if($result!=false){
		 $msg = "新增文章成功!"  ;
		 }else{
		 $msg = "新增文章失败!"  ;
		 }
		 }
		 $this->ajaxReturn ( "111111", $msg, 200 );
		 */
	  
		if ($mark=="edit"){
			$result = $model->where($condition)->save($data);
			
			$this->resultHandle($result,"修改文章成功！","修改文章失败!");
			/*
			if ($result != -1) {
				$this->success ( "修改文章成功!" );
			}else{
				$this->success($model->getError ()) ;
			}*/
		}else{
			$result = $model->add($data);
			$this->resultHandle($result,"新增文章成功！","新增文章失败!");
/*			if ($result != -1) {
				$this->success ( "新增文章成功!" );

			}else{
				$this->success($model->getError ()) ;
			}*/
		}
	  

	  
	}



}

?>